package com.sec.android.app.myfiles.util.region;

import android.content.Context;

import com.sec.android.app.myfiles.R;
import com.sec.android.app.myfiles.info.AppConstants;

import java.io.File;
import java.util.HashMap;

/**
 * NOT PUBLIC
 * RegionImp class shouldn't be used outside of region package
 */
class ChinaRegionImp extends AbsRegionImp {
    //Use Map to Storage the folder path and description
    private HashMap<String, String> mFolderDescriptionMap;

    ChinaRegionImp() {
        mFolderDescriptionMap = new HashMap<>();
    }

    @Override
    protected String getRegionName() {
        return RegionUtils.CHINA;
    }

    @Override
    protected String getRegionLanguage() {
        return RegionUtils.CHINA_LANGUAGE;
    }

    @Override
    protected String getFolderDescriptionImp(Context context, String path) {
        String ret = null;

        if (mFolderDescriptionMap.size() <= 0) {
            loadFolderDescriptionImp(context);
        }

        if (path != null) {
            ret = mFolderDescriptionMap.get(path);
        }

        return ret;
    }

    private void loadFolderDescriptionImp(Context context) {
        String[] path = context.getResources().getStringArray(R.array.path);
        String[] description = context.getResources().getStringArray(R.array.description);
        if (path.length == description.length) {
            for (int i = 0; i < path.length; i++) {
                mFolderDescriptionMap.put(AppConstants.StoragePath.INTERNAL_ROOT + File.separator + path[i], description[i]);
            }
        }
    }

}
